home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group93b.txt
/
000052_icon-group-sender _Wed Apr 28 13:10:24 1993.msg
< prev
next >
Wrap
Internet Message Format
|
1993-06-16
|
2KB
Received: by cheltenham.cs.arizona.edu; Mon, 3 May 1993 05:25:45 MST
Date: 28 Apr 93 13:10:24 GMT
From: mercury.hsi.com!mlfarm!cs.arizona.edu!icon-group@uunet.uu.net (Jerry D. Nowlin)
Subject: Re: Help!
Message-Id: <9304281310.AA23936@iwtqg>
Sender: icon-group-request@cs.arizona.edu
To: icon-group@cs.arizona.edu
Status: R
Errors-To: icon-group-errors@cs.arizona.edu
> erholm@CS.ColoState.EDU (scott erholm) writes:
>
> In Pascal, I could pass values to and from procedures in this manner:
>
> Procedure P (VAR x, y, z : Integer; l, m : Real);
> (* procedure body *)
> end;
>
> And the call to P would look like this:
>
> P (a, b, c, 10, 20);
>
> meaning that procedure P would get 10 and 20 for l and m, and would
> pass the values of x, y, and z back to the calling program.
In Icon you can pass a list into a procedure and then stuff things into it
or yank things out of it and when the procedure exits the list remains
modified. If you pass an empty list to a procedure you can put the x, y
and z values in it and access them from the calling routine. An empty
table may be more convenient if you want to access the values returned in a
specific order.
Finally, while an Icon procedure can only return one item, that item can be
a list or table or any other Icon type. Rather than including an empty
list or table in the parameter list why not just return one you constructed
on the fly inside the procedure. Icon magically keeps the values in the
list or table around for you until you don't need them anymore. Oh sure...
you could explain it in terms of pointers and that other technical stuff
but I like magic.
procedure main()
addem(l := [],t := table())
every write(!l | t[1 to 3] | !retem())
end
procedure addem(l,t)
every put(l,"new"|"list"|"items")
t[1] := "and"
t[2] := "table"
t[3] := "values"
end
procedure retem()
every put(l := [],"and"|"more"|"list"|"items")
return l
end
Jerry Nowlin
nowlin@iwtqg.att.com (work)
isidev!nowlin@uunet.uu.net (home)